/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.other.mapper.impl;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.ResultSetProcessor;
import com.yonyou.iuap.yms.param.SQLParameter;
import com.yonyou.iuap.yms.processor.AutoBeanListProcessor;
import com.yonyou.iuap.yms.processor.AutoBeanProcessor;
import com.yonyou.iuap.yms.processor.ColumnProcessor;
import com.yonyou.ucf.mdf.app.isvdxq.other.entity.OrgBaseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.Types;
import java.util.List;

@Repository
public class OrgBaseMapperImpl {
    
    @Autowired
    private IYmsJdbcApi ymsJdbcApi;
    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.deleteByPrimaryKeyByOrgId
    
    public int deleteByPrimaryKeyByOrgId(String id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "delete from dxqyy_orgbase where `id` = ?\n";
        parameter.addParamWithType(id, Types.VARCHAR);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.selectByOrgId
    
    public List<OrgBaseEntity> selectByOrgId(String id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxqyy_orgbase where `id`=?;\n";
        parameter.addParam(id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new OrgBaseEntity());
        return (List<OrgBaseEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.updateByPrimaryKey
    
    public int updateByPrimaryKey(OrgBaseEntity record) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "update dxqyy_orgbase set `parentid` = ?, `parentid_name` = ?, `dr` = ?, `enable` = ?, `effectivedate` = ?, `pubts` = ?, `finorgid` = ?, `finorgid_name` = ?, `parentorgid` = ?, `parentorgid_name` = ?, `currency` = ?, `currency_name` = ?, `periodschema` = ?, `periodschema_name` = ?, `isinternalaccounting` = ?, `isexternalaccounting` = ? where `id` = ? and `orgtype` = ? and `ytenant_id` = ?\n";
        parameter.addParamWithType(record.getParentid(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentid_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getDr(), Types.INTEGER);
		parameter.addParamWithType(record.getEnable(), Types.INTEGER);
		parameter.addParamWithType(record.getEffectivedate(), Types.VARCHAR);
		parameter.addParamWithType(record.getPubts(), Types.VARCHAR);
		parameter.addParamWithType(record.getFinorgid(), Types.VARCHAR);
		parameter.addParamWithType(record.getFinorgid_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentorgid(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentorgid_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getCurrency(), Types.VARCHAR);
		parameter.addParamWithType(record.getCurrency_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getPeriodschema(), Types.VARCHAR);
		parameter.addParamWithType(record.getPeriodschema_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getIsinternalaccounting(), Types.BIT);
		parameter.addParamWithType(record.getIsexternalaccounting(), Types.BIT);
		parameter.addParamWithType(record.getId(), Types.VARCHAR);
		parameter.addParamWithType(record.getOrgtype(), Types.VARCHAR);
		parameter.addParamWithType(record.getTenant_id(), Types.VARCHAR);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.insert
    
    public int insert(OrgBaseEntity record) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "insert into dxqyy_orgbase (`id`, `parentid`,  `parentid_name`, `dr`,  `enable`, `effectivedate`,  `pubts`, `finorgid`,  `finorgid_name`, `parentorgid`,  `parentorgid_name`, `currency`,  `currency_name`, `periodschema`,  `periodschema_name`, `isinternalaccounting`,  `isexternalaccounting`,`orgtype`,`tenant_id`,`ytenant_id`) values ";
        sql += "(?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?, ?, ?,?, ?)";
        parameter.addParamWithType(record.getId(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentid(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentid_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getDr(), Types.INTEGER);
		parameter.addParamWithType(record.getEnable(), Types.INTEGER);
		parameter.addParamWithType(record.getEffectivedate(), Types.VARCHAR);
		parameter.addParamWithType(record.getPubts(), Types.VARCHAR);
		parameter.addParamWithType(record.getFinorgid(), Types.VARCHAR);
		parameter.addParamWithType(record.getFinorgid_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentorgid(), Types.VARCHAR);
		parameter.addParamWithType(record.getParentorgid_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getCurrency(), Types.VARCHAR);
		parameter.addParamWithType(record.getCurrency_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getPeriodschema(), Types.VARCHAR);
		parameter.addParamWithType(record.getPeriodschema_name(), Types.VARCHAR);
		parameter.addParamWithType(record.getIsinternalaccounting(), Types.BIT);
		parameter.addParamWithType(record.getIsexternalaccounting(), Types.BIT);
		parameter.addParamWithType(record.getOrgtype(), Types.VARCHAR);
        parameter.addParamWithType(record.getTenant_id(), Types.VARCHAR);
		parameter.addParamWithType(record.getTenant_id(), Types.VARCHAR);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.selectCount
    
    public int selectCount(String id, String orgtype, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from dxqyy_orgbase where `id`=? and `orgtype` = ? and `ytenant_id`=?;\n";
        parameter.addParam(id);
		parameter.addParam(orgtype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.deleteByPrimaryKey
    
    public int deleteByPrimaryKey(String id, String orgtype) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "delete from dxqyy_orgbase where `id` = ? and `orgtype`=?\n";
        parameter.addParamWithType(id, Types.VARCHAR);
		parameter.addParam(orgtype);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.selectById
    
    public OrgBaseEntity selectById(String id, String orgtype) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxqyy_orgbase where `id`=? and `orgtype`=?;\n";
        parameter.addParam(id);
		parameter.addParam(orgtype);

        ResultSetProcessor processor = new AutoBeanProcessor(new OrgBaseEntity());
        return (OrgBaseEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.other.mapper.OrgBaseMapper.selectCountByOrgId
    
    public int selectCountByOrgId(String id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from dxqyy_orgbase where `id`=?;\n";
        parameter.addParam(id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

}
